package com.phoenix.es.controller;

import com.phoenix.es.pojo.Product;
import com.phoenix.es.service.ProductSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("search")
public class SearchController {

    @Autowired
    private ProductSearchService service;

    @GetMapping("products")
    public List<Product> getProducts() {
        return service.findAll();
    }

    @PostMapping("save")
    public String  saveProduct(@RequestBody Product product) {
        service.save(product);
        return "success";
    }

}
